//
//  XWChildServerTableViewCell.swift
//  XWSurSpeed
//
//  Created by hopemobi-1 on 2024/8/6.
//

import UIKit

class XWChildServerTableViewCell: UITableViewCell {

    @IBOutlet weak var XWCountryImageView: UIImageView!
    
    @IBOutlet weak var XWCountryLabel: UILabel!
    
    @IBOutlet weak var XWMessageLabel: UILabel!
    
    @IBOutlet weak var XWPinglabel: UILabel!
    
    @IBOutlet weak var XWBackView: UIView!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        
    }
    var childModel:XWServerListModel? {
        didSet {
            XWCountryImageView.sd_setImage(with: URL.init(string: childModel?.flag ?? ""), placeholderImage:UIImage.init(named: "logo_default") )
            XWCountryLabel.text = childModel?.country
            XWPinglabel.text = (childModel?.ping)! + " ms"
            if (childModel?.isConnectVPN)! {
                XWBackView.backgroundColor = hexStringToColor(hexString: "0x674FF7", alpha: 1.0)
            }else{
                XWBackView.backgroundColor = kClearColor
            }
        }
    }
    var indexCellRow:Int? {
        didSet {
            if indexCellRow == 0{
                XWMessageLabel.text = "Priority"
                XWMessageLabel.textColor = hexStringToColor(hexString: "0xFFF618", alpha: 1.0)
            }else{
                XWMessageLabel.text = "Second"
                XWMessageLabel.textColor = hexStringToColor(hexString: "0x03E1FF", alpha: 1.0)
            }
        }
    }
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        self.selectionStyle = .none
        // Configure the view for the selected state
    }
    
}
